﻿using System.Threading.Tasks;
using System.Web.Mvc;
using ControllerExtensibility.Models;

namespace ControllerExtensibility.Controllers
{
    public class RemoteDataController : Controller
    {
        //
        // GET: /RemoteData/
        [TimeElapsedProfile]
        public ViewResult Index()
        {
            return View("Data", (object)"Index of Remote data");
        }

        [TimeElapsedProfile]
        public ViewResult DataSyncCall()
        {
            var srvc = new RemoteService();
            var s = srvc.GetRemoteData();
            return View("Data", (object)s);
        }

        [TimeElapsedProfile]
        public async Task<ActionResult> DataAsync()
        {
            var data = await Task<string>.Factory.StartNew(() => new RemoteService().GetRemoteData());
            return View("Data", (object)data);
        }

        [TimeElapsedProfile]
        public async Task<ActionResult> DataAsync2()
        {
            var data = await new RemoteService().GetRemoteDataAsync();
            return View("Data", (object)data);
        }
    }
}